package com.basic.im.api.controller;import cn.hutool.core.collection.CollectionUtil;import cn.hutool.core.date.DateUnit;import cn.hutool.core.util.ObjectUtil;import cn.hutool.core.util.StrUtil;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONObject;import com.alipay.util.AliPayUtil;import com.basic.common.model.PageVO;import com.basic.im.api.service.AuthServiceOldUtils;import com.basic.im.api.service.AuthServiceUtils;import com.basic.im.api.service.base.AbstractController;import com.basic.im.comm.constants.KConstants;import com.basic.im.comm.constants.KConstants.ResultCode;import com.basic.im.comm.constants.KConstants.Room_Role;import com.basic.im.comm.ex.ServiceException;import com.basic.im.comm.ex.VerifyUtil;import com.basic.im.comm.utils.DateUtil;import com.basic.im.comm.utils.ReqUtil;import com.basic.im.config.AppConfig;import com.basic.im.entity.StickDialog;import com.basic.im.friends.entity.Friends;import com.basic.im.friends.service.FriendsManager;import com.basic.im.open.service.GroupHelperService;import com.basic.im.pay.constants.PayResultCode;import com.basic.im.pay.entity.BaseConsumeRecord;import com.basic.im.pay.service.impl.ConsumeRecordManagerImpl;import com.basic.im.room.entity.Room;import com.basic.im.room.entity.Room.Member;import com.basic.im.room.entity.Room.Notice;import com.basic.im.room.service.RoomCoreRedisRepository;import com.basic.im.room.service.impl.RoomManagerImplForIM;import com.basic.im.room.vo.RoomPayVO;import com.basic.im.room.vo.RoomVO;import com.basic.im.user.config.WXConfig;import com.basic.im.user.entity.AuthKeys;import com.basic.im.user.entity.User;import com.basic.im.user.service.AllowRequestClientService;import com.basic.im.user.service.RoleCoreService;import com.basic.im.user.service.StickDialogService;import com.basic.im.user.service.UserCoreService;import com.basic.im.user.service.impl.AuthKeysServiceImpl;import com.basic.im.user.service.impl.UserManagerImpl;import com.basic.im.utils.ConstantUtil;import com.basic.im.utils.MongoUtil;import com.basic.im.utils.SKBeanUtils;import com.basic.im.vo.JSONMessage;import com.basic.utils.StringUtil;import com.google.common.collect.Maps;import com.wxpay.utils.WXPayUtil;import com.wxpay.utils.WxPayDto;import io.swagger.annotations.Api;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;import lombok.extern.slf4j.Slf4j;import org.bson.types.ObjectId;import org.redisson.api.RSet;import org.redisson.api.RedissonClient;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletRequest;import java.text.DecimalFormat;import java.text.MessageFormat;import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Optional;import java.util.stream.Collectors;import static com.basic.im.comm.constants.KConstants.ALLOW_GRAB_REDPACKET;/** * 群组接口 *  * @author Administrator * */@Api(value="RoomController",tags="群组接口")@RestController@Slf4j@RequestMapping(value ="/room",method={RequestMethod.GET , RequestMethod.POST})public class RoomController extends AbstractController {	@Autowired	private UserManagerImpl userManager;	@Autowired	private RoomManagerImplForIM roomManager;	@Autowired	private AuthKeysServiceImpl authKeysService;	@Autowired	private FriendsManager friendsManager;	@Autowired	private GroupHelperService groupHelperService;	@Autowired	private AppConfig appConfig;	@Autowired	private UserCoreService userCoreService;	@Autowired(required = false)	private RoleCoreService roleCoreService;	@Autowired(required = false)	private AllowRequestClientService allowRequestClientService;	@Autowired(required = false)	private AuthServiceOldUtils authServiceOldUtils;	@Autowired(required = false)	private ConsumeRecordManagerImpl consumeRecordManager;	@Autowired	private WXConfig wxConfig;	@Autowired(required = false)	private AuthServiceUtils authServiceUtils;	@Autowired(required = false)	private RoomCoreRedisRepository roomCoreRedisRepository;	@Autowired	private RedissonClient redissonClient;	@RequestMapping("/addAllowList")	public JSONMessage addAllowList(@RequestParam String roomId,@RequestParam String userId){		String[] tmp = userId.split(",");		for(String t: tmp){			redissonClient.getSet(ALLOW_GRAB_REDPACKET+roomId).add(t);		}		return JSONMessage.success();	}	@RequestMapping("/delAllowList")	public JSONMessage delAllowList(@RequestParam String roomId,@RequestParam String userId){		String[] tmp = userId.split(",");		for(String t: tmp){			redissonClient.getSet(ALLOW_GRAB_REDPACKET+roomId).remove(t);		}		return JSONMessage.success();	}	@RequestMapping("/getAllowList")	public JSONMessage getAllowList(@RequestParam String roomId){		RSet<String> set = redissonClient.getSet(ALLOW_GRAB_REDPACKET + roomId);		return JSONMessage.success(set);	}	/**	 * 新增房间	 */	@ApiOperation("创建群组")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="room" , value="群组实体",dataType="Object",required=true),		@ApiImplicitParam(paramType="query" , name="text" , value="要加入群组的用户userId集合（json字符串）",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="keys" , value="钥匙",dataType="String",required=true)	})	@RequestMapping("/add")	public JSONMessage add(@ModelAttribute Room room, @RequestParam(defaultValue = "") String text, @RequestParam(defaultValue = "") String keys) {		int isCommonCreateGroup = SKBeanUtils.getImCoreService().getClientConfig().getIsCommonCreateGroup();		if (1 == isCommonCreateGroup) {			// 权限校验			byte role = (byte) roleCoreService.getUserRoleByUserId(ReqUtil.getUserId());			if (!(role == KConstants.Admin_Role.SUPER_ADMIN || role == KConstants.Admin_Role.ADMIN)) {				throw new ServiceException(KConstants.ResultCode.BanOrdinaryUsersCreateRoom);			}		}		if(!allowRequestClientService.isAllowRequest(getRequestIp())){			return JSONMessage.failureByErrCode(KConstants.ResultCode.BanOrdinaryUsersCreateRoom);		}		List<Integer> idList = StringUtil.isEmpty(text) ? null : JSON.parseArray(text, Integer.class);		JSONObject userKeys = (!StringUtil.isEmpty(keys) && room.getIsSecretGroup()==1) ? JSON.parseObject(keys):null;		Object data = null;		try {			data = roomManager.add(userManager.getUser(ReqUtil.getUserId()), room, idList,userKeys);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}		return JSONMessage.success(data);	}	/**	 * 删除房间	 *	 * @param roomId	 * @return	 */	@ApiOperation("删除房间")	@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true)	@RequestMapping("/delete")	public JSONMessage delete(@RequestParam String roomId) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(Room_Role.CREATOR!=role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			roomManager.delete(roomObjId,userId);			redissonClient.getSet(ALLOW_GRAB_REDPACKET+roomId).delete();			return JSONMessage.success();		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 更新房间	 * @param roomId	 * @param roomVO	 * @return	 */	@ApiOperation("更新房间")	@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true)	@RequestMapping("/update")	public JSONMessage update(@RequestParam String roomId,			@ModelAttribute RoomVO roomVO) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(0>role||Room_Role.MEMBER==role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			User user = userManager.getUser(userId);			roomVO.setRoomId(new ObjectId(roomId));			Object result= roomManager.update(user, roomVO,1,0);			return JSONMessage.success(result);		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 设置付费群聊	 * @param roomId	 * @param roomPayVO	 * @return	 */	@ApiOperation("设置付费群聊")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomPayVO" , value="群组实体",dataType="Object",required=true),			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组id",dataType="String",required=true),	})	@RequestMapping("/setPay")	public JSONMessage setPay(@RequestParam String roomId,							  @ModelAttribute RoomPayVO roomPayVO) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {				throw new ServiceException(ResultCode.ParamsAuthFail);			}			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(0>role||Room_Role.MEMBER==role) {				return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);			}			User user = userManager.getUser(userId);			roomPayVO.setRoomId(new ObjectId(roomId));			Object result= roomManager.setPay(user, roomPayVO);			return JSONMessage.success(result);		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 更新群组加密类型	 * @param roomId	 * @param encryptType	* @return	 */	@ApiOperation("更新群组加密类型")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="encryptType" , value="加密类型",dataType="int",required=true,defaultValue = "0")	})	@RequestMapping("/updateEncryptType")	public JSONMessage updateEncryptType(@RequestParam String roomId,										 @RequestParam(defaultValue = "0") int encryptType ) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(Room_Role.CREATOR!=role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			roomManager.updateEncryptType(room,encryptType);			return JSONMessage.success();		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 重置群组 chatGroppKey	 * @param roomId	 * @return	 */	@ApiOperation("重置群组 chatGroupKey")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="keys" , value="加密Key",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/resetGroupChatKey")	public JSONMessage resetGroupChatKey(@RequestParam String roomId,										 @RequestParam(defaultValue = "") String keys ) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(Room_Role.CREATOR!=role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			JSONObject userKeys = (!StringUtil.isEmpty(keys) && room.getIsSecretGroup()==1) ? JSON.parseObject(keys):null;			roomManager.resetGroupChatKey(room,userKeys);			return JSONMessage.success();		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("修改自己的群组 chatGroupKey")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="key" , value="chatGroupKey",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/updateGroupChatKey")	public JSONMessage updateGroupChatKey(@RequestParam String roomId,										 @RequestParam(defaultValue = "") String key ) {		try {			int userId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)||StringUtil.isEmpty(key)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(0>role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			roomManager.updateGroupChatKey(room, userId,key);			return JSONMessage.success();		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 获取群组成员 RSA 公钥	 * @param roomId	 * @param userId  群组成员 用户Id	 * @return	 */	@ApiOperation("获取群组成员 RSA 公钥")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="userId" , value="用户编号",dataType="int",required=true,defaultValue = "0")	})	@RequestMapping("/getMemberRsaPublicKey")	public JSONMessage getMemberRsaPublicKey(@RequestParam String roomId,										 @RequestParam(defaultValue = "0") int userId ) {		try {			int myuserId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId = new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int myrole = roomManager.findMemberAndRole(roomObjId,myuserId);			int role = roomManager.findMemberAndRole(roomObjId,userId);			if(0>myrole||0>role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			AuthKeys authKeys = authKeysService.getAuthKeys(userId);			if(null!=authKeys&&null!=authKeys.getMsgRsaKeyPair()){				Map<String,String> result=new HashMap<>(1);				result.put("rsaPublicKey",authKeys.getMsgRsaKeyPair().getPublicKey());				return JSONMessage.success(result);			}			return JSONMessage.failure("该成员不是端对端账号");		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 获取群组所有成员 RSA 公钥	 * @param roomId	 * @return	 */	@ApiOperation("获取群组所有成员 RSA 公钥")	@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true)	@RequestMapping("/getAllMemberRsaPublicKey")	public JSONMessage getAllMemberRsaPublicKey(@RequestParam String roomId) {		try {			int myuserId=ReqUtil.getUserId();			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(roomId)) {                throw new ServiceException(ResultCode.ParamsAuthFail);            }			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int myrole = roomManager.findMemberAndRole(roomObjId,myuserId);			if(0==myrole) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			List<Integer> memberIdList = roomManager.getMemberIdList(roomObjId);			Map<String, String> resultMap = authKeysService.queryUseRSAPublicKeyList(memberIdList);			return JSONMessage.success(resultMap);		} catch (Exception e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 根据房间Id获取群组	 * 包括 成员 列表	 * 公告列表	 * @param roomId	 * @return	 */	@ApiOperation("根据房间Id获取群组")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页",dataType="int",required=true,defaultValue = ""),		@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页数据量",dataType="int",required=true,defaultValue = "500"),	})	@RequestMapping("/get")	public JSONMessage get(@RequestParam(defaultValue = "") String roomId,@RequestParam(defaultValue="0") Integer pageIndex,@RequestParam(defaultValue="100") Integer pageSize) {		try {			ObjectId roomObjId;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			Room data = roomManager.get(roomObjId,pageIndex,pageSize);			if(null==data) {                return JSONMessage.failureByErrCode(ResultCode.NotRoom);            }			data.setMember(roomManager.getMember(roomObjId, ReqUtil.getUserId()));			if (data.getUserSize()>50) {				data.setShowRead((byte)0);			}			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	* @Description: TODO(只获取群组属性和群主管理员信息， 不包括 成员列表 和公告列表)	* @param @param roomId	* @param @return    参数	 */	@ApiOperation("只获取群组属性和群主管理员信息， 不包括 成员列表 和公告列表")	@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true)	@RequestMapping("/getRoom")	public JSONMessage getRoom(@RequestParam String roomId) {		try {			ObjectId roomObjId=null;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			} 			Room data = roomManager.getRoom(roomObjId);			if(null==data) {                return JSONMessage.failureByErrCode(ResultCode.NotRoom);            }			data.setMember(roomManager.getMember(roomObjId, ReqUtil.getUserId()));			if (data.getUserSize()>50) {                data.setShowRead((byte) 0);            }			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * @Description: TODO(只检测过期时间是否超过30天)	 * @param @param roomId	 * @param @return    参数	 */	@ApiOperation("检测过期时间是否超过30天")	@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true)	@RequestMapping("/checkDeadLine")	public JSONMessage checkDeadLine(@RequestParam String roomId) {		try {			ObjectId roomObjId=null;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			Room data = roomManager.getRoom(roomObjId);			if(null==data) {				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			Member member = roomManager.getMember(roomObjId, ReqUtil.getUserId());			if(member==null||member.getRole()==1||member.getRole()==2){				//群主管理员,不做处理				return JSONMessage.success();			}			Long deadLine = member.getDeadLine();			Date deadDate = new Date(deadLine);			long between = cn.hutool.core.date.DateUtil.between(new Date(), deadDate, DateUnit.DAY);			if (between<30) {				return JSONMessage.failure("还有"+between+"天到期请尽快续费");			}			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * @Description: TODO(只检测过期时间是否超过30天)	 * @param @param roomId	 * @param @return    参数	 */	@ApiOperation("检测过期时间是否超过30天")	@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true)	@RequestMapping("/checkInRoom")	public JSONMessage checkInRoom(@RequestParam String roomJid) {		try {			Room data = roomManager.getRoomInfoAndMemberByJid(roomJid);			if(null==data) {				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			Member member = roomManager.getMember(data.getId(), ReqUtil.getUserId());			if(member!=null){				return JSONMessage.success();			}			return JSONMessage.failure("不在群里");		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * @Description: TODO(只获取群组属性和群主管理员信息， 不包括 成员列表 和公告列表)	 * @param @param roomId	 * @param @return    参数	 */	@ApiOperation("通过jid获取群组属性和群主管理员信息， 不包括 成员列表 和公告列表")	@ApiImplicitParam(paramType="query" , name="roomJid" , value="群组jid",dataType="String",required=true)	@RequestMapping("/getRoomByJid")	public JSONMessage getRoomByJid(@RequestParam String roomJid) {		try {			Room data = roomManager.getRoomInfoAndMemberByJid(roomJid);			if (null == data) {                return JSONMessage.failureByErrCode(ResultCode.NotRoom);            }			data.setMember(roomManager.getMember(data.getId(), ReqUtil.getUserId()));			if (data.getUserSize() > 50) {                data.setShowRead((byte) 0);            }			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("转让群主")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="toUserId" , value="目标用户编号",dataType="int",required=true,defaultValue = "0"),	})	@RequestMapping("/transfer")	public JSONMessage transfer(@RequestParam String roomId,@RequestParam(defaultValue="0") Integer toUserId) {		if(0==toUserId) {            return JSONMessage.failureByErrCode(ResultCode.SpecifyNewOwner);        }		ObjectId roomObjId=null;		try {			roomObjId=new ObjectId(roomId);		}catch (Exception e){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		Room room = roomManager.getRoom(roomObjId);		if(null==room) {            return JSONMessage.failureByErrCode(ResultCode.NotRoom);        }		if(room.getS() == -1) {            return JSONMessage.failureByErrCode(ResultCode.RoomIsLock);        } else if(toUserId.equals(room.getUserId())) {            return JSONMessage.failureByErrCode(ResultCode.NotTransferToSelf);        } else if(!ReqUtil.getUserId().equals(room.getUserId())) {            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);        }		Member member = roomManager.getMember(roomObjId, toUserId);		if (null== member) {			return JSONMessage.failureByErrCode(ResultCode.NotGroupMember);		}else if(1==member.getIsBlack()){			return JSONMessage.failureByErrCode(ResultCode.NotTransferBackMember);		}		try {			roomManager.transfer(room, toUserId);		}catch (Exception e){			return JSONMessage.failureByException(e);		}		return JSONMessage.success();	}	/**	 * 获取房间列表（按创建时间排序）	 *	 * @param pageIndex	 * @param pageSize	 * @return	 */	@ApiOperation("获取房间列表")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页码数",dataType="int",required=true,defaultValue = "0"),		@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页数据条数",dataType="int",defaultValue = "10"),		@ApiImplicitParam(paramType="query" , name="roomName" , value="群名称（用于搜索）",dataType="String"),		@ApiImplicitParam(paramType="query" , name="isJoinGroup" , value="是否查询加入群组标志",dataType="int"),		@ApiImplicitParam(paramType="query" , name="isSearchAllJoinGroup" , value="搜索加入的群组,包括私密，不公开（0否  1是）",dataType="int"),	})	@RequestMapping("/list")	public JSONMessage list(@RequestParam(defaultValue = "0") int pageIndex,							@RequestParam(defaultValue = "10") int pageSize,							@RequestParam(defaultValue = "") String roomName,							@RequestParam(defaultValue = "0") int isJoinGroup,							@RequestParam(defaultValue = "0") int isSearchAllJoinGroup) {		Object data =null;		if(0==appConfig.getIsBeta()) {            data=roomManager.selectList(pageIndex, pageSize, MongoUtil.tranKeyWord(roomName),isJoinGroup,ReqUtil.getUserId(),isSearchAllJoinGroup);        }		return JSONMessage.success(data);	}	@ApiOperation("添加群成员")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="int",required=true),			@ApiImplicitParam(paramType="query" , name="member" , value="成员对象",dataType="int"),			@ApiImplicitParam(paramType="query" , name="inviteUserId" , value="邀请用户",dataType="int"),			@ApiImplicitParam(paramType="query" , name="text" , value="要添加的成员用户Id集合（用于搜索）",dataType="String"),			@ApiImplicitParam(paramType="query" , name="keys" , value="钥匙",dataType="String"),			@ApiImplicitParam(paramType="query" , name="version" , value="版本，用于兼容旧版本（被邀请加群确认）0：旧版 1：新版",dataType="int"),			@ApiImplicitParam(paramType="query" , name="operationType" , value="类型：（用于分辨用户操作类型 0：其他操作，1：审核通过，2：用户邀请入群，3：用户付费邀请）",dataType="int")	})	@RequestMapping("/member/update")	public JSONMessage updateMember(@RequestParam String roomId,									@ModelAttribute Member member,									@RequestParam(defaultValue = "0") Integer inviteUserId,									@RequestParam(defaultValue = "") String text,									@RequestParam(defaultValue = "") String keys,									@RequestParam(defaultValue = "0") int version,									@RequestParam(defaultValue = "0") int operationType) {		try {			List<Integer> idList = StringUtil.isEmpty(text) ? null : JSON.parseArray(text, Integer.class);			User user = userManager.getUser(ReqUtil.getUserId());			ObjectId roomObjId=null;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			if(StringUtil.isEmpty(text)&&null==member.getUserId()) {				return JSONMessage.failureByErrCode(ResultCode.ParamsLack);			}else if(StringUtil.isEmpty(text)&&					(null==member.getTalkTime()&&StringUtil.isEmpty(member.getRemarkName())					&&0==member.getRole()&&StringUtil.isEmpty(member.getNickname())						)) {				return JSONMessage.failureByErrCode(ResultCode.ParamsLack);			}			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}else{				if(-1 == room.getS()) {                    return JSONMessage.failureByErrCode(ResultCode.RoomIsLock);                }				if (null == idList){					Member optMember = roomManager.getMember(roomObjId, user.getUserId());					int role= roomManager.findMemberAndRole(roomObjId, member.getUserId());					if(null==optMember) {                        return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                    } else if(1!=optMember.getRole()&&role==Room_Role.ADMIN&&!optMember.getUserId().equals(user.getUserId())) {                        return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                    } else if(!StringUtil.isEmpty(member.getNickname())&&!optMember.getUserId().equals(member.getUserId())) {                        return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                    } else if(!user.getUserId().equals(member.getUserId())&&1!=optMember.getRole()&&role==Room_Role.ADMIN) {                        return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                    }					if(null!=member.getTalkTime()) {						if(role== KConstants.Room_Role.CREATOR) {                            return JSONMessage.failureByErrCode(ResultCode.NotGroupMember);                        } else if(optMember.getRole()==Room_Role.MEMBER) {                            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                        }					}					roomManager.updateMember(user, roomObjId, member,operationType,inviteUserId);				}else{					if(1==room.getIsNeedVerify()&&!user.getUserId().equals(room.getUserId())) {                        return JSONMessage.failureByErrCode(ResultCode.InviteNeedAgree);                    }					if(!user.getUserId().equals(room.getUserId())&&1==idList.size()){						if(null==friendsManager.getFriends(user.getUserId(), idList.get(0))) {                            return JSONMessage.failureByErrCode(ResultCode.NotFriendNoInvite);                        }					}					JSONObject userKeys = (!StringUtil.isEmpty(keys) && room.getIsSecretGroup()==1) ? JSON.parseObject(keys):null;					Map<String,List<Integer>> failList = roomManager.updateMember(user, roomObjId, idList, userKeys,operationType,inviteUserId);					StringBuffer buffer = new StringBuffer();					String msg = null;					if(null != failList.get("noticeUserIds") && failList.get("noticeUserIds").size() > 0){						failList.get("noticeUserIds").forEach(id ->buffer.append(userCoreService.getNickName(id)).append(","));						msg = ConstantUtil.getMsgByCode(KConstants.ResultCode.BEINVITATION_GROUP_CONFIRM + "", ReqUtil.getRequestLanguage());						msg = MessageFormat.format(msg, buffer.toString());					}					JSONObject jsonObject = new JSONObject();					jsonObject.put("msg",msg);					jsonObject.put("userIds",failList.get("noticeUserIds"));					jsonObject.put("failList",failList.get("failList"));					// 旧版本只返回已经在群组中的userId列表					if(0 == version){						return JSONMessage.success(failList.get("failList"));					}					return JSONMessage.success(jsonObject);				}			}		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}		return JSONMessage.success();	}	/**	 * 购买付费群	 * @param payType	 * @param price	 * @param time	 * @param secret	 * @return	 */	@ApiOperation("购买付费群")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId",value="群组id",dataType="int"),			@ApiImplicitParam(paramType="query" , name="periods",value="周期数",dataType="int"),			@ApiImplicitParam(paramType="query" , name="payType",value="支付类型",dataType="int"),			@ApiImplicitParam(paramType="query" , name="price",value="价格",dataType="String"),			@ApiImplicitParam(paramType="query" , name="time",value="时间",dataType="String"),			@ApiImplicitParam(paramType="query" , name="secret",value="加密数据",dataType="String"),			@ApiImplicitParam(paramType="query" , name="salt",value="盐加密",dataType="String")	})	@RequestMapping(value = "/pay/getSign")	public JSONMessage getSign(HttpServletRequest request,							   @RequestParam String roomId,							   @RequestParam int periods,							   @RequestParam int payType,							   @RequestParam String price,							   @RequestParam(defaultValue="0") long time,							   @RequestParam(defaultValue="") String secret,							   String salt) {		String token=getAccess_token();		Integer userId = ReqUtil.getUserId();		if(StringUtil.isEmpty(salt)){			//充值接口授权			if(!authServiceOldUtils.authRedPacket(userId+"", token, time, secret)) {				return JSONMessage.failureByErrCode(KConstants.ResultCode.AUTH_FAILED);			}		}		//判断用户数是否已经在群组里面//		if (roomManager.memberExists(new ObjectId(roomId), userId)) {//			throw new ServiceException(KConstants.ResultCode.UserIsAlreadyInGroup);//		}		// 处理充值自定义输入金额超过两位数		DecimalFormat df = new DecimalFormat("0.00");		Double money = new Double(price);		if(0.01>money){			return JSONMessage.failureByErrCode(PayResultCode.PleaseEnterAmount);		}		// 判断单笔消费金额是否超过限制		if(money>SKBeanUtils.getImCoreService().getPayConfig().getMaxRechargeAmount()){			return JSONMessage.failureByErrCode(PayResultCode.ExceedMaxAmount);		}		// 判断单日消费金额是否超过限制		Double todayMoney = consumeRecordManager.getUserPayMoney(userId,KConstants.ConsumeType.USER_RECHARGE,KConstants.OrderStatus.END, com.basic.utils.DateUtil.getTodayMorning().getTime()/1000 , com.basic.utils.DateUtil.getTodayNight().getTime()/1000);		todayMoney = todayMoney + money;		if(todayMoney > SKBeanUtils.getImCoreService().getPayConfig().getDayMaxRechargeAmount()){			return JSONMessage.failureByErrCode(PayResultCode.ExceedDayMaxAmount);		}		//重复验证        VerifyUtil.isRollback(!roomCoreRedisRepository.removeInviteCode(userId,new ObjectId(roomId)), KConstants.ResultCode.INVITE_LOST_EFFICACY);		price = df.format(money);		Map<String,String> map= Maps.newLinkedHashMap();		String orderInfo="";		if(0<payType){			String orderNo=StringUtil.getOutTradeNo();			BaseConsumeRecord entity=new BaseConsumeRecord();			entity.setMoney(money);			/*if(10<entity.getMoney()) {				return JSONMessage.failureByErrCode(PayResultCode.SingleRechargeUpTen);			}*/			entity.setUserId(ReqUtil.getUserId());			entity.setTime(com.basic.utils.DateUtil.currentTimeSeconds());			entity.setType(KConstants.ConsumeType.ADD_ROOM);			entity.setChangeType(KConstants.MOENY_ZERO);			entity.setDesc("Pay to join the group chat");			entity.setStatus(KConstants.OrderStatus.CREATE);			entity.setTradeNo(orderNo);			entity.setPayType(payType);			//targetId设置为群组的id			entity.setTargetId(new ObjectId(roomId));			entity.setNum(periods);			if (KConstants.PayType.ALIPAY == payType) {				if(1 != SKBeanUtils.getImCoreService().getClientConfig().getEnableAliPay()){					return JSONMessage.failureByErrCode(KConstants.ResultCode.FUNCTION_NOTOPEN);				}				orderInfo = AliPayUtil.getOrderInfo("付费加入群聊", "付费加入群聊", price, orderNo);				consumeRecordManager.saveConsumeRecord(entity);				map.put("orderInfo", orderInfo);				logger.info("orderInfo : " + orderInfo);				return JSONMessage.success(null, map);			}else {				if(1 != SKBeanUtils.getImCoreService().getClientConfig().getEnableWxPay()){					return JSONMessage.failureByErrCode(KConstants.ResultCode.FUNCTION_NOTOPEN);				}				WxPayDto tpWxPay = new WxPayDto();				//tpWxPay.setOpenId(openId);				tpWxPay.setBody("付费加入群聊");				tpWxPay.setOrderId(orderNo);				tpWxPay.setSpbillCreateIp(request.getRemoteAddr());				tpWxPay.setTotalFee(price);				consumeRecordManager.saveConsumeRecord(entity);				Object data= WXPayUtil.getPackage(tpWxPay,wxConfig);				return JSONMessage.success(data);			}		}		return JSONMessage.failureByErrCode(PayResultCode.NotSelectPayType);	}	@ApiOperation("余额支付加入群聊")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="codeId" , value="标识码",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="data" , value="加密数据",dataType="String",required=true)	})	@RequestMapping("/pay/balance")	public JSONMessage balancePay(			@RequestParam(defaultValue="") String codeId,									   @RequestParam(defaultValue="") String data) {		Integer userId = ReqUtil.getUserId();		String token=getAccess_token();		User user=userCoreService.getUser(userId);		// 授权校验		JSONObject jsonObject = authServiceUtils.authJoinRoom(userId, token, data, codeId, user.getPayPassword());		if(null==jsonObject) {			return JSONMessage.failureByErrCode(KConstants.ResultCode.AUTH_FAILED);		}		String roomId = jsonObject.getString("roomId");		Double price = jsonObject.getDouble("price");		int periods = jsonObject.getInteger("periods");		JSONMessage result= null;		if(price> SKBeanUtils.getImCoreService().getPayConfig().getMaxTransferAmount()){			return JSONMessage.failureByErrCode(PayResultCode.ExceedMaxAmount);		}		// 判断用户单日转账金额		Double todayMoney = consumeRecordManager.getUserPayMoney(userId,KConstants.ConsumeType.SEND_TRANSFER,KConstants.OrderStatus.END, DateUtil.getTodayMorning().getTime()/1000 ,DateUtil.getTodayNight().getTime()/1000);		todayMoney = todayMoney + price;		if(todayMoney>SKBeanUtils.getImCoreService().getPayConfig().getDayMaxTransferAmount()){			return JSONMessage.failureByErrCode(PayResultCode.ExceedDayMaxAmount);		}		//判断用户数是否已经在群组里面//		if (roomManager.memberExists(new ObjectId(roomId), userId)) {//			throw new ServiceException(KConstants.ResultCode.UserIsAlreadyInGroup);//		}		try {			result = roomManager.payForJoin(userId,price,roomId,periods);		} catch (Exception e) {			return JSONMessage.failureByException(e);		}		return result;	}	//退出群组	@ApiOperation("退出群组")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="userId" , value="要删除的成员Id",dataType="int",required=true)	})	@RequestMapping("/member/delete")	public JSONMessage deleteMember(@RequestParam String roomId, @RequestParam int userId) {		try {			User user = userManager.getUser(ReqUtil.getUserId());			ObjectId roomObjId=null;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			if(-1 == room.getS()){				return JSONMessage.failureByErrCode(ResultCode.RoomIsLock);			}			int role = roomManager.findMemberAndRole(roomObjId,ReqUtil.getUserId());			int toRole = roomManager.findMemberAndRole(roomObjId,userId);			if(0>role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            } else if(userId!=user.getUserId()) {				if(Room_Role.MEMBER==role) {                    return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                }				if(Room_Role.ADMIN==role&&Room_Role.ADMIN==toRole) {                    return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);                }			}			roomManager.deleteMember(user,roomObjId, userId,false);			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@Autowired	private StickDialogService stickDialogService;	/** @Description:群消息的置顶和消息免打扰	* @param offlineNoPushMsg 0:关闭,1:开启	* @param roomId	* @param userId	* @param type = 0  消息免打扰 ,type = 1 聊天置顶	* @return	**/	@ApiOperation("群消息的置顶和消息免打扰")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="offlineNoPushMsg" , value="是否开启消息免打扰、聊天置顶0:关闭，1：开启",dataType="int",defaultValue = "0"),		@ApiImplicitParam(paramType="query" , name="type" , value="0 :消息免打扰 , 1: 聊天置顶,",dataType="int"),		@ApiImplicitParam(paramType="query" , name="userId" , value="用户Id",dataType="int")	})	@RequestMapping("/member/setOfflineNoPushMsg")	public JSONMessage setOfflineNoPushMsg(@RequestParam(defaultValue="0") int offlineNoPushMsg,@RequestParam String roomId,@RequestParam int userId,@RequestParam(defaultValue="0") int type){		ObjectId roomObjId=null;		try {			roomObjId=new ObjectId(roomId);		}catch (Exception e){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}        int userId1 = ReqUtil.getUserId();        int role = roomManager.findMemberAndRole(roomObjId, userId1);        if(0>role) {            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);        }		Room room = roomManager.getRoom(roomObjId);		if(null == room){			return JSONMessage.failureByErrCode(ResultCode.NotRoom);		}		Integer offlineUserId = (0 != userId ? userId : userId1);		roomManager.Memberset(offlineNoPushMsg, roomObjId, offlineUserId,type);		if(1==type){			if(1==offlineNoPushMsg){				stickDialogService.add(new StickDialog()						.setUserId(userId1)						.setJid(room.getJid()).setIsRoom(KConstants.ONE)						.setTime(DateUtil.currentTimeSeconds())				);			}else {				stickDialogService.delete(userId1,room.getJid());			}		}		return JSONMessage.success();	}	@ApiOperation("设置拉取漫游截止时间")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true),	})	@RequestMapping("/member/setBeginMsgTime")	public JSONMessage setBeginMsgTime(@RequestParam String roomId) {		try {			Integer userId = ReqUtil.getUserId();			ObjectId roomObjId=null;			try {				roomObjId=new ObjectId(roomId);			}catch (Exception e){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			if(-1 == room.getS()){				return JSONMessage.failureByErrCode(ResultCode.RoomIsLock);			}			int role = roomManager.findMemberAndRole(roomObjId, userId);			if(0>role) {				return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);			}			roomManager.setBeginMsgTime(roomObjId,userId);			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("设置群组隐藏会话")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId",value="群组ID",dataType="String"),			@ApiImplicitParam(paramType="query" , name="hideChatSwitch",value="hideChatSwitch",dataType="byte"),	})	@RequestMapping(value ="/member/setHideChatSwitch")	public JSONMessage setHideChatPassword(@RequestParam(defaultValue = "") String roomId,byte hideChatSwitch){		roomManager.setHideChatSwitch(new ObjectId(roomId),ReqUtil.getUserId(),hideChatSwitch);		return JSONMessage.success();	}	@ApiOperation("查询群是否存在")	@RequestMapping(value ="/exists")	public JSONMessage roomExists(@RequestParam(defaultValue = "",name = "jid") String jid,								  @RequestParam(defaultValue = "",name = "roomId") String roomIdStr){		boolean exists = false;		if (StrUtil.isNotBlank(jid)){			exists = ObjectUtil.isNotNull(roomManager.getRoomByJid(jid));		}		if (StrUtil.isNotBlank(roomIdStr) && ObjectId.isValid(roomIdStr)){			exists = ObjectUtil.isNotNull(roomManager.getRoom(new ObjectId(roomIdStr)));		}		return JSONMessage.success(exists);	}	@ApiOperation("设置群组隐藏会话")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId",value="群组ID",dataType="String"),			@ApiImplicitParam(paramType="query" , name="hideChatSwitch",value="hideChatSwitch",dataType="byte"),	})	@RequestMapping(value ="/member/exists")	public JSONMessage memberExists(@RequestParam(defaultValue = "") String jid,Integer userId){		ObjectId roomId = VerifyUtil.verifyObjectId(roomManager.getRoomIdByJid(jid));		return JSONMessage.success(roomManager.memberExists(roomId,userId));	}	@ApiOperation("获取成员详情，包含用户信息")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="int",required=true),			@ApiImplicitParam(paramType="query" , name="userId" , value="目标成员userId",dataType="int",required=true,defaultValue = "0")	})	@RequestMapping("/member/get/details")	public JSONMessage getMemberDetails(@RequestParam String roomId, @RequestParam(defaultValue="0") int userId){		if(0==userId) {			userId=ReqUtil.getUserId();		}		if (userId==0 || StrUtil.hasBlank(roomId)){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		Member member = roomManager.getMember(new ObjectId(roomId),userId);		if(null == member){			return JSONMessage.failureByErrCode(ResultCode.MemberNotInGroup);		}		User user = (userId==ReqUtil.getUserId()) ? userManager.getUser(userId):userManager.getUser(ReqUtil.getUserId(),userId);		if (null == user){			return JSONMessage.failureByErrCode(ResultCode.UserNotExist);		}		//查找用户公私钥		Optional<AuthKeys> authKeys = Optional.ofNullable(authKeysService.getAuthKeys(userId));		if (authKeys.isPresent()) {			user.setDhMsgPublicKey((authKeys.get().getMsgDHKeyPair() != null) ? authKeys.get().getMsgDHKeyPair().getPublicKey() : null);			user.setDhMsgPrivateKey((authKeys.get().getMsgDHKeyPair() != null) ? authKeys.get().getMsgDHKeyPair().getPrivateKey() : null);			user.setRsaMsgPublicKey((authKeys.get().getMsgRsaKeyPair() != null) ? authKeys.get().getMsgRsaKeyPair().getPublicKey() : null);			user.setRsaMsgPrivateKey((authKeys.get().getMsgRsaKeyPair() != null) ? authKeys.get().getMsgRsaKeyPair().getPrivateKey() : null);		}		if (ReqUtil.getUserId() != userId) { // 用户获取他人的用户信息			user.buildNoSelfUserVo(ReqUtil.getUserId());		} else {			// 客户端请求不将用户支付密码返回,只返回用户是否设置了密码 ,0用户未设置密码, 1用户已设置密码			user.setPayPassword(StringUtil.isEmpty(authKeysService.getPayPassword(ReqUtil.getUserId())) ? "0" : "1");		}		user.setBalance(null);		Map<String,Object> resultMap = new HashMap<>();		resultMap.put("user", user);		resultMap.put("member", member);		return JSONMessage.success(resultMap);	}	@ApiOperation("获取成员详情")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="int",required=true),		@ApiImplicitParam(paramType="query" , name="userId" , value="目标成员userId",dataType="int",required=true,defaultValue = "0")	})	@RequestMapping("/member/get")	public JSONMessage getMember(@RequestParam String roomId, @RequestParam(defaultValue="0") int userId) {		if(0==userId) {            userId=ReqUtil.getUserId();        }		ObjectId roomObjId=null;		try {			roomObjId=new ObjectId(roomId);		}catch (Exception e){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		Room room = roomManager.getRoom(roomObjId);		if(null == room){			return JSONMessage.failureByErrCode(ResultCode.NotRoom);		}		Member data = roomManager.getMember(roomObjId, userId);		if(data==null) {            return JSONMessage.failureByErrCode(ResultCode.MemberNotInGroup);        }		/*if(StringUtil.isEmpty(data.getCall()))			data.setCall(roomManager.getCall(roomObjId));		if(StringUtil.isEmpty(data.getVideoMeetingNo()))			data.setVideoMeetingNo(roomManager.getVideoMeetingNo(roomObjId));*/		return JSONMessage.success(data);	}	@ApiOperation("查询群成员")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="keyword" , value="关键字",dataType="String",required=true)	})	@RequestMapping("/member/list")	public JSONMessage getMemberList(@RequestParam String roomId,@RequestParam(defaultValue="") String keyword) {		Object data=null;		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,ReqUtil.getUserId());			if(0>role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			 data = roomManager.getMemberList(roomObjId,keyword);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}		return JSONMessage.success(data);	}	@ApiOperation("群成员列表分页")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组d",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="joinTime" , value="连接时间",dataType="long",defaultValue = "0"),			@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页",dataType="int"),			@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页数据量",dataType="int",defaultValue = "100"),			@ApiImplicitParam(paramType="query" , name="keyword" , value="模糊搜索key",dataType="int",defaultValue = "")	})	@RequestMapping("/member/getMemberListByPage")	public JSONMessage getMemberListByPage(@RequestParam(defaultValue="") String roomId,										   @RequestParam(defaultValue="0") long joinTime,										   @RequestParam(defaultValue="") String keyword,										   @RequestParam(defaultValue="") Integer pageIndex,										   @RequestParam(defaultValue="100") Integer pageSize) {		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId,ReqUtil.getUserId());			if (0 > role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			List<Member> memberListByPage = roomManager.getMemberListByPageImpl(roomObjId,joinTime,pageSize,keyword);			return JSONMessage.success(memberListByPage);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("获取群组公告列表")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="keyword" , value="重要单元",dataType="String",required=true,defaultValue = ""),		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true)	})	@RequestMapping("/notice/list")	public JSONMessage getNoticeList(@RequestParam String roomId,@RequestParam(defaultValue="") String keyword) {		Object data = roomManager.getNoticeList(new ObjectId(roomId));		return JSONMessage.success(data);	}	//获取房间	@ApiOperation("获取房间")	@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true)	@RequestMapping("/get/call")	public JSONMessage getRoomCall(@RequestParam String roomId){		Object data=roomManager.getCall(new ObjectId(roomId));		return JSONMessage.success(data);	}	@ApiOperation("加入群组")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="type" , value="1=自己的房间；2=加入的房间",dataType="int",defaultValue = "2"),			@ApiImplicitParam(paramType="query" , name="operationType" ,					value="加群方式：0：搜索加群，1：扫码加群,2:附近的群，3：榜单加群，4：搜索付费加群，5：扫码付费加群，6：附近付费加群，7：榜单付费加群",					dataType="int"			)	})	@RequestMapping("/join")	public JSONMessage join(@RequestParam String roomId,							@RequestParam(defaultValue = "2") int type,							@RequestParam(name = "operationType",defaultValue = "0") int operationType) {		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			roomManager.join(ReqUtil.getUserId(),roomObjId, type,operationType,0);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}		return JSONMessage.success();	}	@ApiOperation("用户历史房间列表")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="type" , value="0=所有；1=自己的房间；2=加入的房间（默认为0）",dataType="int",defaultValue = "0"),		@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页码数",dataType="int",defaultValue = "0"),		@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页数据条数",dataType="int",defaultValue = "10")	})	@RequestMapping("/list/his")	public JSONMessage historyList(@RequestParam(defaultValue = "0") int type,			@RequestParam(defaultValue = "0") int pageIndex, @RequestParam(defaultValue = "10") int pageSize) {		Object data = null;		try {			data = roomManager.selectHistoryList(ReqUtil.getUserId(), type, pageIndex, pageSize);		}catch (ServiceException e){			JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		return JSONMessage.success(data);	}	//设置/取消管理员	@ApiOperation("设置/取消 管理员 ")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="touserId" , value="目标用户id",dataType="int"),		@ApiImplicitParam(paramType="query" , name="type" , value="角色值 1=创建者、2=管理员、3=成员",dataType="int")	})	@RequestMapping("/set/admin")	public JSONMessage setAdmin(@RequestParam String roomId,@RequestParam int touserId,@RequestParam int type){		try {			Integer userId = ReqUtil.getUserId();			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomObjId, userId);			if(Room_Role.CREATOR!=role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			if(touserId == userId) {                return JSONMessage.failureByErrCode(ResultCode.RoomOwnerNotSetAdmin);            }			roomManager.setAdmin(roomObjId, touserId,type, userId);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}		return JSONMessage.success();	}	/** @Description:（设置/取消 隐身人、监护人（其他人完全看不到他；隐身人和监控人的区别是，前者不可以说话，后者能说话））	* @param roomId 房间id	* @param touserId  被指定人 	* @param type 4:设置隐身人  -1:取消隐身人，5：设置监控人，0：取消监控人	* @return	**/	@ApiOperation("设置/取消 隐身人、监护人（其他人完全看不到他；隐身人和监控人的区别是，前者不可以说话，后者能说话")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="房间id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="touserId" , value="被指定人",dataType="int"),		@ApiImplicitParam(paramType="query" , name="type" , value="4:设置隐身人  -1:取消隐身人，5：设置监控人，0：取消监控人",dataType="int")	})	@RequestMapping("/setInvisibleGuardian")	public JSONMessage setInvisibleGuardian(@RequestParam String roomId,@RequestParam int touserId,@RequestParam int type){		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			if(roomManager.getMember(roomObjId, ReqUtil.getUserId()).getRole()!=1) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			Member member = roomManager.getMember(roomObjId,touserId);			if(null == member) {                return JSONMessage.failureByErrCode(ResultCode.MemberNotInGroup);            }			int role = member.getRole();// 成员角色：1=创建者、2=管理员、3=普通成员、4=隐身人、5=监控人			if((4 == type && role != 3)||(5 == type && role !=3)){				return JSONMessage.failureByErrCode(ResultCode.NotRepeatOperation);			}			if(-1 == type && role != 4){				return JSONMessage.failureByErrCode(ResultCode.MemberNotInvisible);			}			if(0 == type && role != 5){				return JSONMessage.failureByErrCode(ResultCode.MemberNotMonitor);			}			roomManager.setInvisibleGuardian(new ObjectId(roomId), touserId,type,ReqUtil.getUserId());		} catch (Exception e) {		}		return JSONMessage.success();	}	//添加（群共享）	@ApiOperation("添加群共享")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="type" , value="类型",dataType="int",required=true),		@ApiImplicitParam(paramType="query" , name="size" , value="文件大小",dataType="long",required=true),		@ApiImplicitParam(paramType="query" , name="userId" , value="上传者userId",dataType="int",required=true),		@ApiImplicitParam(paramType="query" , name="url" , value="文件url",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="name" , value="文件名称",dataType="String",required=true)	})	@RequestMapping("/add/share")	public JSONMessage addShare(@RequestParam ObjectId roomId,@RequestParam int type,@RequestParam float size,@RequestParam int userId			,@RequestParam String url,@RequestParam String name){		try {			Room room = roomManager.getRoom(roomId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			int role = roomManager.findMemberAndRole(roomId,ReqUtil.getUserId());			if(0>role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			Object data=roomManager.Addshare(roomId,size,type ,userId, url,name);			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	//查询(群共享)	@ApiOperation("查询群共享")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="access_token" , value="访问令牌",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="time" , value="时间（用于搜索）",dataType="String"),		@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页码数",dataType="String"),		@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页数据条数",dataType="int"),		@ApiImplicitParam(paramType="query" , name="userId" , value="用户id",dataType="int")	})	@RequestMapping("/share/find")	public JSONMessage findShare(@RequestParam ObjectId roomId,								 @RequestParam(defaultValue="0") int pageIndex,								 @RequestParam(defaultValue="0") long time,								 @RequestParam(defaultValue="0") int userId,								 @RequestParam(defaultValue="10") int pageSize){		Room room = roomManager.getRoom(roomId);		if(null == room){			return JSONMessage.failureByErrCode(ResultCode.NotRoom);		}		int role = roomManager.findMemberAndRole(roomId,ReqUtil.getUserId());		if(KConstants.ZERO > role) {            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);        }		Object data=roomManager.findShare(roomId, time, userId, pageIndex, pageSize);		return JSONMessage.success(data);	}	@ApiOperation("获取群共享详情")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="房间Id",dataType="ObjectId",required=true),		@ApiImplicitParam(paramType="query" , name="shareId" , value="共享文件Id",dataType="ObjectId",required=true)	})	@RequestMapping("/share/get")	public JSONMessage getShare(@RequestParam ObjectId roomId,@RequestParam ObjectId shareId){		Room room = roomManager.getRoom(roomId);		if(null == room){			return JSONMessage.failureByErrCode(ResultCode.NotRoom);		}		int role = roomManager.findMemberAndRole(roomId,ReqUtil.getUserId());		if(0>role) {            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);        }		Object data=roomManager.getShare(roomId, shareId);		return JSONMessage.success(data);	}	//删除	@ApiOperation("删除群共享")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="shareId" , value="共享文件Id",dataType="String"),	})	@RequestMapping("/share/delete")	public JSONMessage deleteShare(@RequestParam String roomId,@RequestParam String shareId){		ObjectId roomObjId=null;		ObjectId shareObjId=null;		try {			roomObjId=new ObjectId(roomId);			shareObjId=new  ObjectId(shareId);		}catch (Exception e){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		int userId=ReqUtil.getUserId();		Room room = roomManager.getRoom(roomObjId);		if(null == room){			return JSONMessage.failureByErrCode(ResultCode.NotRoom);		}		final Room.Share share = roomManager.getShare(roomObjId, shareObjId);		if(null==share) {            return JSONMessage.failureByErrCode(ResultCode.DataNotExists);        }		int role = roomManager.findMemberAndRole(roomObjId,userId);		if((0>role||Room_Role.MEMBER==role)&&userId!=share.getUserId()) {            return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);        }		roomManager.deleteShare(roomObjId,shareObjId,userId);		return JSONMessage.success();	}	//删除群公告	@ApiOperation("删除群公告")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="noticeId" , value="公告ID",dataType="String",required=true)	})	@RequestMapping("/notice/delete")	public JSONMessage deleteNotice(@RequestParam(defaultValue = "") String roomId,			@RequestParam(defaultValue = "") String noticeId) {		ObjectId roomObjId=new ObjectId(roomId);		Integer userId = ReqUtil.getUserId();		try {			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			if (StringUtil.isEmpty(roomId) || StringUtil.isEmpty(noticeId)) {				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			int role = roomManager.findMemberAndRole(roomObjId, userId);			if(0>role||Room_Role.MEMBER==role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			roomManager.deleteNotice(userId,roomObjId, new ObjectId(noticeId));			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	/**	 * 发送群消息	 *  @return	 */	@ApiOperation("发送群消息")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="jidArr" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="userId" , value="用户编号",dataType="int",required=true,defaultValue = "1"),			@ApiImplicitParam(paramType="query" , name="type" , value="类型",dataType="int",required=true,defaultValue = "1"),			@ApiImplicitParam(paramType="query" , name="content" , value="内容",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/sendMsg")	public JSONMessage sendMsg (@RequestParam(defaultValue="") String jidArr,@RequestParam(defaultValue="1") int userId,			@RequestParam(defaultValue="1") int type,@RequestParam(defaultValue="")String content){		String[] split = jidArr.split(",");		roomManager.sendMsgToRooms(split, userId, type, content);		return JSONMessage.success();	}	/** @Description:（公告列表）	* @param roomId	* @param pageIndex	* @param pageSize	* @return	**/	@ApiOperation("公告列表")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="房间登入",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="pageIndex" , value="当前页",dataType="int",defaultValue = "0"),		@ApiImplicitParam(paramType="query" , name="pageSize" , value="每页大小",dataType="int",defaultValue = "10")	})	@RequestMapping("/noticesPage")	public JSONMessage noticesPage(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue = "0") int pageIndex,@RequestParam(defaultValue = "10") int pageSize){		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			PageVO noticeList = roomManager.getNoticeList(roomObjId, pageIndex, pageSize);			return JSONMessage.success(noticeList);		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	@ApiOperation("确认查看群组公告")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间ID",dataType="String",required=true),	})	@RequestMapping("/notices/read")	public JSONMessage noticesRead(@RequestParam(defaultValue="") String roomId){		try {			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			roomManager.readNotice(roomObjId,ReqUtil.getUserId());			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	@ApiOperation("通过时间查询公告列表")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="startTime" , value="开始时间",dataType="int",defaultValue = "0")	})	@RequestMapping("/noticeList/byTime")	public JSONMessage noticeListByTime(@RequestParam String roomId,										@RequestParam(defaultValue = "0") long startTime,										@RequestParam(defaultValue = "10") int limit){		try {			ObjectId roomObjId = new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			Object noticeList = roomManager.getNoticeListByTime(roomObjId, startTime, limit);			return JSONMessage.success(noticeList);		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	@ApiOperation("获取单个群组公告")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="noticeId" , value="公告Id",dataType="String",required=true)	})	@RequestMapping("/notice/findOne")	public JSONMessage getOneNotice(@RequestParam String roomId, @RequestParam String noticeId) {		if(!ObjectId.isValid(roomId) || !ObjectId.isValid(noticeId)){			return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);		}		Object data = roomManager.getNoticeById(new ObjectId(roomId),new ObjectId(noticeId));		return JSONMessage.success(data);	}	/** @Description:修改群公告	* @param roomId	* @param noticeId	* @param noticeContent	* @return	**/	@ApiOperation("修改群公告")	@ApiImplicitParams({		@ApiImplicitParam(paramType="query" , name="roomId" , value="群编号",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="noticeId" , value="注意编号",dataType="String",required=true),		@ApiImplicitParam(paramType="query" , name="noticeContent" , value="注意内容",dataType="String",required=true)	})	@RequestMapping("/updateNotice")	public JSONMessage updateNotice(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="") String noticeId,@RequestParam(defaultValue="") String noticeContent){		try {			Integer userId = ReqUtil.getUserId();			ObjectId roomObjId=new ObjectId(roomId);			Room room = roomManager.getRoom(roomObjId);			if(null == room){				return JSONMessage.failureByErrCode(ResultCode.NotRoom);			}			if(StringUtil.isEmpty(noticeContent) || StringUtil.isEmpty(roomId) || StringUtil.isEmpty(noticeId)) {                return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);            }			int role = roomManager.findMemberAndRole(roomObjId,ReqUtil.getUserId());			if(0>role||Room_Role.MEMBER==role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			Notice updateNotice = roomManager.updateNotice(roomObjId, new ObjectId(noticeId), noticeContent,userId);			return JSONMessage.success(updateNotice);		} catch (ServiceException e) {			return JSONMessage.failure(e.getMessage());		}	}	@ApiOperation("查询房间")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="name" , value="名称",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="longitude" , value="精度",dataType="double",required=true),			@ApiImplicitParam(paramType="query" , name="latitude" , value="维度",dataType="double",required=true),			@ApiImplicitParam(paramType="query" , name="password" , value="密码",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="isQuery" , value="是否查询",dataType="int",required=true),	})	@RequestMapping("/location/query")	public JSONMessage queryLocationRoom(String name,double longitude,double latitude,String password,int isQuery){		try {			Room room = roomManager.queryLocationRoom(name, longitude, latitude, password,isQuery);			return JSONMessage.success(room);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("连接房间")	@ApiImplicitParam(paramType="query" , name="jid" , value="编号",dataType="String",required=true)	@RequestMapping("/location/join")	public JSONMessage joinLocationRoom(String jid){		try {			Room room =roomManager.joinLocationRoom(jid);			return JSONMessage.success(room);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("退出房间")	@ApiImplicitParam(paramType="query" , name="jid" , value="编号",dataType="String",required=true)	@RequestMapping("/location/exit")	public JSONMessage exitLocationRoom(String jid){		try {			roomManager.exitLocationRoom(jid);			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 添加群助手	 * @return	 */	@ApiOperation("添加群助手")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="helperId" , value="群助手编号",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间编号",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="roomJid" , value="编号",dataType="String",required=true)	})	@RequestMapping("/addGroupHelper")	public JSONMessage addGroupHelper(@RequestParam String helperId,@RequestParam String roomId,@RequestParam String roomJid){		try {			Integer userId = ReqUtil.getUserId();			Object data = groupHelperService.addGroupHelper(helperId,roomId,roomJid,userId);			return JSONMessage.success(data);		} catch (Exception e) {			e.printStackTrace();			return JSONMessage.failure(e.getMessage());		}	}	/**	 * 添加自动回复关键字	 * @param roomId	 * @param keyword	 * @param value	 * @return	 */	@ApiOperation("添加自动回复关键字")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="helperId" , value="群助手编号",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间编号",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="roomJid" , value="编号",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="value" , value="值",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="keyword" , value="钥匙",dataType="String",required=true)	})	@RequestMapping("/addAutoResponse")	public JSONMessage addAutoResponse(@RequestParam(defaultValue="") String helperId,@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="") String keyword,@RequestParam(defaultValue="") String value){		try {			Object data = groupHelperService.addAutoResponse(roomId, helperId,keyword, value);			return JSONMessage.success(data);		} catch (Exception e) {			e.printStackTrace();			return JSONMessage.failure(e.getMessage());		}	}	/**	 * 更新自动回复关键字及回复	 * @param keyWordId	 * @param keyword	 * @param value	 * @return	 */	@ApiOperation("更新自动回复关键字及回复")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="groupHelperId" , value="群助手编号",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="keyWordId" , value="重要单元编号",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="keyword" , value="重要单元",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="value" , value="值",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/updateAutoResponse")	public JSONMessage updateKeyWord(@RequestParam(defaultValue="") String groupHelperId,@RequestParam(defaultValue="") String keyWordId,@RequestParam(defaultValue="") String keyword,@RequestParam(defaultValue="") String value){		try {			Object data = groupHelperService.updateKeyword(groupHelperId,keyWordId, keyword, value);			return JSONMessage.success(data);		} catch (Exception e) {			e.printStackTrace();			return JSONMessage.failure(e.getMessage());		}	}	/**	 * 删除自动回复关键字	 * @param groupHelperId	 * @param keyWordId	 * @return	 */	@ApiOperation("删除自动回复关键字")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="groupHelperId" , value="群助手编号",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="keyWordId" , value="重要单元编号",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/deleteAutoResponse")	public JSONMessage deleteAutoResponse(@RequestParam(defaultValue="") String groupHelperId,@RequestParam(defaultValue="") String keyWordId){		try {			Object data = groupHelperService.deleteAutoResponse(ReqUtil.getUserId(),groupHelperId, keyWordId);			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 删除群助手	 * @return	 */	@ApiOperation("删除群助手")	@ApiImplicitParam(paramType="query" , name="groupHelperId" , value="群助手编号",dataType="String",required=true,defaultValue = "")	@RequestMapping("/deleteGroupHelper")	public JSONMessage deleteGroupHelper(@RequestParam(defaultValue="") String groupHelperId){		try {			groupHelperService.deleteGroupHelper(ReqUtil.getUserId(),groupHelperId);			return JSONMessage.success();		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/**	 * 查询房间群助手	 * @param roomId	 * @return	 */	@ApiOperation("查询房间群助手")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" , value="房间编号",dataType="String",required=true,defaultValue = ""),			@ApiImplicitParam(paramType="query" , name="helperId" , value="群助手编号",dataType="String",required=true,defaultValue = "")	})	@RequestMapping("/queryGroupHelper")	public JSONMessage queryGroupHelper(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="") String helperId){		try {			Object data = groupHelperService.queryGroupHelper(roomId,helperId);			return JSONMessage.success(data);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	/** @Description:群组复制	* @param roomId	* @return	**/	@ApiOperation("群复制 ")	@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true)	@RequestMapping("/copyRoom")	public JSONMessage copyRoom(@RequestParam(defaultValue="") String roomId){		try {			Integer userId = ReqUtil.getUserId();			ObjectId roomObjId=new ObjectId(roomId);			int role = roomManager.findMemberAndRole(roomObjId,ReqUtil.getUserId());			if(Room_Role.CREATOR!=role) {                return JSONMessage.failureByErrCode(ResultCode.NO_PERMISSION);            }			User user = userManager.getUser(userId);			Room copyRoom = roomManager.copyRoom(user, roomId);			return JSONMessage.success(copyRoom);		} catch (ServiceException e) {			return JSONMessage.failureByException(e);		}	}	@ApiOperation("更新群组音视频会议状态")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="type" ,value="状态 0：关闭会议，1：语音会议，2：视频会议",dataType="int",required=true)	})	@RequestMapping("/updateMeetingStaus")	public JSONMessage updateMeetingStatus(@RequestParam(defaultValue="") String roomId, @RequestParam(defaultValue="0") int type){		try {			if(!ObjectId.isValid(roomId)){				return JSONMessage.failureByErrCode(ResultCode.ParamsAuthFail);			}			roomManager.updateMeetingStatus(new ObjectId(roomId),type,ReqUtil.getUserId());		}catch (Exception e){			return JSONMessage.failureByException(e);		}		return JSONMessage.success();	}	@ApiOperation("被邀请用户确认加入群组")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="userId" ,value="邀请的用户Id",dataType="int",required=true),			@ApiImplicitParam(paramType="query" , name="operationType" , value="类型：（用于分辨用户操作类型 0：邀请入群，1：邀请付费入群）",dataType="int")	})	@RequestMapping("/inviteJoinRoom")	public JSONMessage inviteJoinRoom(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="0") Integer userId,@RequestParam(defaultValue="0") Integer operationType) {		roomManager.inviteJoinRoom(ReqUtil.getUserId(), userId, new ObjectId(roomId),operationType);		return JSONMessage.success();	}	@ApiOperation("拉黑群组用户")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="userId" ,value="拉黑的用户Id",dataType="int",required=true),	})	@RequestMapping("/black/add")	public JSONMessage addBlackList(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="0") Integer userId) {		roomManager.editBlackList(ReqUtil.getUserId(), new ObjectId(roomId),1,userId);		return JSONMessage.success();	}	@ApiOperation("取消拉黑群组用户")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true),			@ApiImplicitParam(paramType="query" , name="userId" ,value="取消拉黑的用户Id",dataType="int",required=true),	})	@RequestMapping("/black/remove")	public JSONMessage removeBlackList(@RequestParam(defaultValue="") String roomId,@RequestParam(defaultValue="0") Integer userId) {		roomManager.editBlackList(ReqUtil.getUserId(), new ObjectId(roomId),0,userId);		return JSONMessage.success();	}	@ApiOperation("查询指定群组拉黑用户列表")	@ApiImplicitParams({			@ApiImplicitParam(paramType="query" , name="roomId" ,value="群组Id",dataType="String",required=true)	})	@RequestMapping("/black/list")	public JSONMessage blackMemberList(@RequestParam(defaultValue="") String roomId){		if (StrUtil.hasBlank(roomId)){			return JSONMessage.failureByErrCode(ResultCode.PARAMS_ERROR);		}		List<Member> memberList = roomManager.getBlackMemberList(roomId,1);		return JSONMessage.success(memberList);	}	@ApiOperation("查询指定群组拉黑用户列表")	@RequestMapping("/member/get/names")	public JSONMessage getMemberNames(@RequestParam(name = "roomId") String roomIdStr){		ObjectId roomId = VerifyUtil.verifyObjectId(roomIdStr);		Integer userId  = VerifyUtil.verifyUserId(ReqUtil.getUserId());		return JSONMessage.success(roomManager.getMemberNames(roomId,userId));	}	@ApiOperation("查询指定不在指定群中的好友列表")	@RequestMapping("/member/friends")	public JSONMessage getMemberFriends(@RequestParam(name = "roomId") String roomIdStr,										@RequestParam(name = "keyword") String keyword,										@RequestParam(name = "userType")Integer userType,										@RequestParam(name = "pageIndex",defaultValue = "0")Integer pageIndex,										@RequestParam(name = "pageSize",defaultValue = "20") Integer pageSize){		ObjectId roomId = VerifyUtil.verifyObjectId(roomIdStr);		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		List<Member> members = roomManager.getMembers(roomId,KConstants.ZERO,5000); // 避免查询量过大		if (CollectionUtil.isNotEmpty(members)){			List<Integer>  notInUserIds = members.stream().map(Member::getUserId).collect(Collectors.toList());			return JSONMessage.success(friendsManager.queryFollow(userId,Friends.Status.Friends,userType,notInUserIds,keyword,pageIndex,pageSize));		}		return JSONMessage.success(Collections.emptyList());	}	@ApiOperation("根据名称搜索加入的群组")	@ApiImplicitParams({			@ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页数量，默认10条", dataType = "int", defaultValue = "10"),			@ApiImplicitParam(paramType = "query", name = "pageIndex", value = "当前页 ", dataType = "int"),			@ApiImplicitParam(paramType = "query", name = "keyword", value = "搜索关键词 ", dataType = "String")	})	@RequestMapping("/search")	public JSONMessage searchCollection(@RequestParam(name = "keyword",   defaultValue = "")    String keyword,										@RequestParam(name = "pageIndex", defaultValue = "0")   int pageIndex,										@RequestParam(name = "pageSize",  defaultValue = "10")  int pageSize) {		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		return JSONMessage.success(roomManager.getRoomByUserAndName(userId,keyword,pageIndex,pageSize));	}	@RequestMapping("/setFlag")	public JSONMessage setFlag(@RequestParam(name = "roomId",   defaultValue = "")    String roomId,										@RequestParam(name = "flag", defaultValue = "0")   int flag) {		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		if(!roleCoreService.queryUserRoleIsExist(userId,5)){			return JSONMessage.failureByErrCode(KConstants.ResultCode.NO_PERMISSION);		}		roomManager.setRoomFlag(userId,roomId,flag);		return JSONMessage.success();	}	@RequestMapping("/chekcPermission")	public JSONMessage chekcPermission() {		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		if(!roleCoreService.queryUserRoleIsExist(userId,5)){			return JSONMessage.failureByErrCode(KConstants.ResultCode.NO_PERMISSION);		}		return JSONMessage.success();	}	/*@Autowired(required = false)	private CompanyManager companyManager;	@RequestMapping("/bannedAndClearFlagRoom")	public JSONMessage bannedAndClear(@RequestParam(defaultValue = "") String password) {		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		String dbPwd = authKeysService.queryLoginPassword(userId);		if (StringUtil.isEmpty(password) || (!password.equals(dbPwd)&&				!LoginPassword.encodeFromOldPassword(dbPwd).equals(password))) {			return JSONMessage.failureByErrCode(ResultCode.VERIFYPASSWORDFAIL);		}		log.info("bannedAndClearFlagRoom ===> {}",userId);		roomManager.bannedAndClearFlagRoom(userId);		String companyId=SKBeanUtils.getImCoreService().getAppConfig().getFlagCompanyId();		if(!StrUtil.isEmpty(companyId)){			List<Integer> userIdList = companyManager.queryEmployeeUserIdList(new ObjectId(companyId));			friendsManager.cleanFriendsSecretMsg(userIdList,userId);		}		return JSONMessage.success();	}	@RequestMapping("/destroyFlagRoom")	public JSONMessage destroyFlagRoom(@RequestParam(defaultValue = "") String password) {		Integer userId = VerifyUtil.verifyUserId(ReqUtil.getUserId());		String dbPwd = authKeysService.queryLoginPassword(userId);		if (StringUtil.isEmpty(password) ||(!password.equals(dbPwd)&&				!LoginPassword.encodeFromOldPassword(dbPwd).equals(password))) {			return JSONMessage.failureByErrCode(ResultCode.VERIFYPASSWORDFAIL);		}		log.info("destroyFlagRoom ===> {}",userId);		roomManager.destroyFlagRoom(userId);		String companyId=SKBeanUtils.getImCoreService().getAppConfig().getFlagCompanyId();		if(!StrUtil.isEmpty(companyId)){			List<Integer> userIdList = companyManager.queryEmployeeUserIdList(new ObjectId(companyId));			friendsManager.cleanFriendsAllMsg(userIdList,userId);		}		return JSONMessage.success();	}*/}